
package com.jianjian.demo;

import com.example.radioselectorview.R;
import com.example.radioselectorview.R.id;
import com.example.radioselectorview.R.layout;
import com.jianjian.radioselectorview.RadioSelectorView;
import com.jianjian.radioselectorview.RadioSelectorView.OnChangeListener;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;


public class MainActivity extends Activity {

    private String[] buttonNames = {
            "S1", "SS2", "SSe3", "SSer4"
    };

    private TextView textView;
    private RadioSelectorView rsView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Get RadioSelectorView from XML
        // or you can just new one as you like
        // RadioSelectorView rsView = new RadioSelectorView(context,null);
        setContentView(R.layout.activity_main);
        textView = (TextView) findViewById(R.id.textView);

        rsView = (RadioSelectorView) findViewById(R.id.radioSelectorView);
        rsView.setOnChangeListener(new RadioSelectorView.OnChangeListener() {
            @Override
            public void onChange() {
                textView.setText("Position : " + String.valueOf(rsView.getPosition()));
            }
        });
        /*
         * USE init() FIRST!!! (param1 set number of button in this view)
         */
        rsView.init(4, buttonNames);

        // Init everything before draw();
        // Everything is in dp-unit

        // Set initial position to 2
        rsView.setPosition(2);
        rsView.initButtonHeight(60);
        rsView.draw();
        textView.setText("Position : " + String.valueOf(rsView.getPosition()));
        
    }
}
